<template>
	<view>
		<!-- 顶部导航 -->
		<fa-navbar title="兑换" :border-bottom="false"></fa-navbar>
		<view class="fr-ac py-40 px-40" style="background: #D4D4D4;">
			<view class="" style="color: #F76F21;">
				为了您的权益，请务必核对公司编码、会员卡号信息准确无误!! 
			</view>
		</view>
		<!-- 导航 -->
		<view class="">
			<view class="px-40" style="background: #fff;">
				<view class="fr-ac py-35 u-border-bottom gap-20">
					<view class="flex-1">
						公司编码
					</view>
					<input :disabled="type != 'edit'" v-model="name" class="t-r" type="text" placeholder="请输入公司编码" />
				</view>
				<view class="fr-ac py-35 u-border-bottom gap-20">
					<view class="flex-1">
						会员卡号
					</view>
					<input :disabled="type != 'edit'" v-model="card_num" class="t-r" type="text" placeholder="请输入会员卡号" />
				</view>
			</view>
		</view>
		
		<u-gap height="150"></u-gap>
		<view class="px-40 w-100" style="position: fixed;bottom: 60rpx;left: 0;">
			<view @click="submit" class="br-12 t-c fs-32 py-25" :style="{'background': theme.bgColor,'color': '#fff'}">
				立即兑换
			</view>
		</view>
		
		
	</view>
</template>

<script>
export default {
	onLoad() {
	},
	onShow() {
		
	},
	data() {
		return {
			id: '',
			
			name: '',
			card_num: '',
			bank: '',
			deposit: '',
			
			type: 'edit',
		};
	},
	methods: {
		async submit(){
			if(this.name === ''){
				return this.$u.toast('请填写公司编码')
			}
			if(this.card_num === ''){
				return this.$u.toast('请填写会员卡号')
			}
			
			let res = await this.$api.use_card({
				company_code: this.name,
				card_no: this.card_num
			});
			if (!res.code) {
				this.$u.toast(res.msg);
				return;
			}
			uni.showModal({
				title: '兑换成功！',
				showCancel: false,
				success: (res) => {
					this.name = ''
					this.card_num = ''
				}
			})
		},
	},
	
};
</script>

<style lang="scss">
page {
	background-color: #f4f6f8;
}
</style>
<style lang="scss" scoped>

</style>
